<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
	<ui:param name="pageName" value="Create New Note"></ui:param>
	<ui:define name="sidebar">
	<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
	
		<h:form id="Note">
			<p:growl />
			 <h:outputText value="Important Notes" styleClass="outputTextTitle" />   
			<p:tabView id="Table" > 
				
				<p:tab id="tab1" title="Create Note" >  
					<h:panelGrid columns="2" cellspacing="7">
						<h:outputLabel value="*" style="color:red;"  />
				        <h:outputLabel value="New Note  : "  />						
					</h:panelGrid>
					<p:inputTextarea value="#{createNotesBean.note.note}" autoResize="false" style="width:350px;"/><br/>
					<p:commandButton value="Create" update="@form"  actionListener="#{createNotesBean.confirmationAction}" />
					
				</p:tab> 
				
				<p:tab id="tab2" title="Active Notes"> 				
					<p:dataTable id="ActiveNotes"  value="#{createNotesBean.activeNotes}" var="note" paginator="true" rows="20">   
	     	            <p:column headerText="S.No"> 
			              	<h:outputText value="#{note.sno}" />                 
			            </p:column>  
			            
			            <p:column headerText="Note">
			              	<p:cellEditor>							
								<f:facet name="output">  
				                   <h:outputText value="#{note.note}" /> 
				                </f:facet>  
				                <f:facet name="input">  
				                    <p:inputTextarea value="#{note.note}" autoResize="false" style="width:200px;"/>  
				                </f:facet> 
						    </p:cellEditor>                
			            </p:column>
			  
			            <p:column headerText="Created By"> 
			              	 <h:outputText value="#{note.createdBy}" />                     
			            </p:column>  
			            
			            <p:column headerText="Created On" > 
			              	<h:outputText value="#{note.createDate}" >
			              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{createNotesBean.timeZone}"/>
			              	</h:outputText>                  
			            </p:column>
			            
			            <p:column headerText="Dispaly Order" id="DisplayOrder"> 
			              	 <p:inputText id="Value" value="#{note.displayOrder}" style="width:50px;" maxlength="3"/>                     
			            </p:column>   	
			            
			            <p:column headerText="Status"> 
			              	 <p:selectOneMenu value="#{note.status}" >
					              <f:selectItem itemLabel="#{note.status}" itemValue="#{note.status}" />
					              <f:selectItem itemLabel="#{createNotesBean.inActiveStatus}" itemValue="#{createNotesBean.inActiveStatus}"  />
				             </p:selectOneMenu>       
			            </p:column> 	
			           
			            <p:column headerText="Edit" style="width:50px">  
			            	<p:rowEditor />  
			       		</p:column>              
			           		           
                    </p:dataTable>
                    <p:commandButton  value="Update" update="@form"  actionListener="#{createNotesBean.confirmationActiveNotesAction}" />
					
				</p:tab>
				<p:tab id="tab3" title="Inactive Notes"> 				
					<p:dataTable  value="#{createNotesBean.inActiveNotes}" var="note" paginator="true" rows="20">   
	     	            <p:column headerText="S.No"> 
			              	<h:outputText value="#{note.sno}" />                 
			            </p:column>  
			            
			            <p:column headerText="Note"> 
			              	<h:outputText value="#{note.note}" />                 
			            </p:column>
			  
			            <p:column headerText="Created By"> 
			              	 <h:outputText value="#{note.createdBy}" />                     
			            </p:column>  
			            
			            <p:column headerText="Created On"> 
			              	<h:outputText value="#{note.createDate}" >
			              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{createNotesBean.timeZone}"/>
			              	</h:outputText>                  
			            </p:column> 
			           			            
			             <p:column headerText="Status"> 
			              	 <p:selectOneMenu value="#{note.status}" >
					              <f:selectItem itemLabel="#{note.status}" itemValue="#{note.status}" />
					              <f:selectItem itemLabel="#{createNotesBean.activeStatus}" itemValue="#{createNotesBean.activeStatus}"  />
				             </p:selectOneMenu>       
			            </p:column>	           
                    </p:dataTable>
					<p:commandButton  value="Update" update="@form"  actionListener="#{createNotesBean.confirmationInActiveNotesAction}" />
				</p:tab>
			
			</p:tabView> 
			 <p:confirmDialog widgetVar="confirmation" id="confirmation" severity="alert" message="This will submit your note. Proceed?">
				<h:panelGroup style="text-align: right; float: right;">
					<p:commandButton value="Yes, Submit Now" action="#{createNotesBean.createNewNoteAction}" update="@form" oncomplete="confirmation.hide()"/>
					<p:commandButton id="decline" value="Not Yet" onclick="confirmation.hide()" type="button" />
				</h:panelGroup>
		    </p:confirmDialog>
		    
		    <!-- ACtive Notes -->
		     <p:confirmDialog widgetVar="confirmationActiveNotes" id="confirmationActiveNotes" severity="alert" message="This will update your note(s). Proceed?">
				<h:panelGroup style="text-align: right; float: right;">
					<p:commandButton value="Yes, Update Now" action="#{createNotesBean.updateNotesAction}" update="@form" oncomplete="confirmationActiveNotes.hide()">
						<f:param name="notes" value="activeNotes" />
					</p:commandButton>
					<p:commandButton value="Not Yet" onclick="confirmationActiveNotes.hide()" type="button" />
				</h:panelGroup>
		    </p:confirmDialog>
		    
		    <p:confirmDialog widgetVar="confirmationInActiveNotes" id="confirmationInActiveNotes" severity="alert" message="This will update your note(s). Proceed?">
				<h:panelGroup style="text-align: right; float: right;">
					<p:commandButton  value="Yes, Update Now" action="#{createNotesBean.updateNotesAction}" update="@form" oncomplete="confirmationInActiveNotes.hide()">
						<f:param name="notes" value="inActiveNotes" />
					</p:commandButton>
					<p:commandButton value="Not Yet" onclick="confirmationInActiveNotes.hide()" type="button" />
				</h:panelGroup>
		    </p:confirmDialog>
		    
			
		</h:form>
	</ui:define>
</ui:composition>

